package com.icewld.dus;

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

    Intent HDCAS;
    PermissionDo pd;
    ImageView pic;
    TextView dis_title;
    AlertDialog.Builder dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        HDCAS = new Intent(getBaseContext(), HDCAService.class);
        pd = new PermissionDo(this, this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        pd.checkPermission();
        pic = (ImageView) findViewById(R.id.pic);
        dis_title = (TextView) findViewById(R.id.dis_title);
        dialog = new AlertDialog.Builder(this);
        dialog.setTitle("帮助");
        dialog.setMessage("开启后,任意界面音量下键拍照,音量上键切换摄像头,图片存在根目录/Picture目录下。\n" +
                "注意:\n1.USB调试需打开,否则拍照一次后闪退;\n" +
                "2.开启过程中,返回键失效,无法使用输入法;\n" +
                "3.切换为前置摄像头时停止服务而不退出程序，再次开启服务后无法立即拍照，需要切换摄像头后正常使用(待修复)\n" +
                "开发者邮箱:a1458675007@live.com,感谢使用");
        dialog.setPositiveButton("确定", null);
    }

    public void StartService(View v){
        pd.alterWindowPermission();
        dis_title.setText("随性活！");
        pic.setImageResource(R.drawable.girls_free);
        startService(HDCAS);
        Toast.makeText(getApplicationContext(), "开启成功", Toast.LENGTH_SHORT).show();
    }

    public void StopService (View v){
        dis_title.setText("要乖哦！");
        pic.setImageResource(R.drawable.girls_glass);
        stopService(HDCAS);
        Toast.makeText(getApplicationContext(), "停止成功", Toast.LENGTH_SHORT).show();
    }

    public void Help(View v){
        dialog.show();
    }
}
